home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / 13h_kit / getfont.doc < prev    next >
Text File  |  1991-07-04  |  7KB  |  137 lines

  1. >>> GETFONT.DOC
  2.  
  3. ****************************************************************************
  4.  
  5. Images.Hpp and Images.Cpp along with this document file are copyright 1991
  6. by the Gamers Programming Workshop, GAMERS forum, Compuserve (GO GAMERS,
  7. section 11). The code and related document are free for use, distribution,
  8. and modification, provided the following conditions are met:
  9.  
  10.     1. no commercial use of this source code or documents is permitted.
  11.     2. no fee may be charged beyond disk duplication cost for any of this
  12.        material.
  13.     3. If the code is upgraded or modified a copy of the modification must
  14.        be uploaded to section 11 of the GAMERS forum on Compuserve. All
  15.        modifications must be documented and the author's name included in
  16.        the source code header block, and the subsequent file package must
  17.        include all the original doc files as well as any additions.
  18.  
  19. ****************************************************************************
  20.  
  21. The getfont.cpp program can be used to capture fonts you have designed and
  22. saved as a PCX format file. This is not a polished command line program,
  23. but rather a source code framework which you can modify to get and work
  24. with your own fonts. In it's original form the program is set up to capture
  25. a font from FONT1.PCX and create the file CSFONT1.FNT. This is the font
  26. included with this package. The first step is to create the font as a PCX
  27. file. This can be done with any paint program that works with these files.
  28.  
  29. The capture program currently supports 3 rows of 32 characters. This allows
  30. you to capture the standard keyboard set. The program could easily be mod-
  31. ified to capture the full 256 character set.
  32.  
  33. Lay the font out as in the example pcx FONT1.PCX inlcuded in this package.
  34. The characters must be alligned with no whitespace between them, in rows
  35. such that each row has the same number of characters. Use only two colors,
  36. a background color and a foreground color. It does not matter which two you
  37. use. Decide on a character frame size (the sample font is 6 x 6 pixels), and
  38. then allign these frames in rows. Generally the characters will not be as
  39. wide or as tall as the character frame. In the sample font the widest char-
  40. acters (such as 'W') occupy the top left 5 x 5 pixels. The leftover line at
  41. the bottom is used for descenders, and the column on the right is left
  42. empty. You may choose any frame size and allignment that you wish, but keep
  43. the character allignment consistent throughout the font for best results.
  44.  
  45. When you have the characters drawn, save them as a pcx, and then edit the
  46. source code for getfont as described in the section that follows.
  47.  
  48. Font file format:    bytes    description
  49.                   -----------------------------------------------------
  50.                      0..7     font name, eight characters
  51.                      8        width of character frame in pixels
  52.                      9        height of character frame in pixels
  53.                      10       y distance from top of character to baseline
  54.                      11       ascii code of first defined character
  55.                      12       ascii code of last defined character
  56.                      13       font foreground color
  57.  
  58.                      14..141  128 byte character width table
  59.                      142..?   Cursor mask
  60.  
  61. The font bitmap itself is stored immediately after the cursor mask. At run-
  62. time the size of the cursor mask is determined by:
  63.  
  64.             header.fram_wid * header.fram_hit
  65.  
  66. So the cursor mask should always have the same dimensions as the character
  67. frame.
  68.  
  69. To modify the getfont program to capture your own font, you must revise the
  70. data which is stored in the first 160 or so bytes of the file. The values
  71. which will be written to the first 14 bytes (as described above) are stored
  72. in the following structure (showing the data for the example font):
  73.  
  74. struct header {                     // font description structure
  75.     char  font_name[8];             // font name, no file extension
  76.     char  fram_wid;                 // width of character frame in pixels
  77.     char  fram_hit;                 // height of character frame in pixels
  78.     char  base_ofs;                 // baseline y offset from top
  79.     char  ascii_first;              // number of first character defined
  80.     char  ascii_last;               // number of last character defined
  81.     char f_color;                   // original font foreground color
  82.  
  83. } HDR={"CSFONT1",6,6,5,0x20,0x7F,15};  // <<-----FILL IN HERE
  84.  
  85. Once you've set up this data you need to enter the character widths into the
  86. character width table. This table is used to display the characters with
  87. their proportional widths, resulting in much nicer looking text. This is
  88. about the worst part of making a font <g>. Here is the width table from the
  89. example font. The character widths are in ascii ascending order.
  90.  
  91. char width[128] = {4,2,3,5,5,5,5,2,2,2,2,4,2,2,2,5,4,2,4,4,4,4,4,4,4,
  92.                    4,2,2,5,4,5,4,5,4,4,4,4,4,4,4,4,3,4,4,4,5,5,4,4,4,
  93.                    4,4,4,4,4,5,5,4,4,2,5,2,5,5,2,5,4,4,4,4,3,4,4,3,4,
  94.                    4,2,5,4,4,4,4,4,4,3,4,4,5,4,4,4,2,2,2,4,5};
  95.  
  96. Next, the cursor mask must be defined. Use 0's for background, and 1's for
  97. foreground. This cursor will be displayed whenever you get user input from
  98. screen using the font class. Here is the cursor from the sample font, which
  99. is a diamond shape:
  100.  
  101. char cursor_mask[6][6]= {0,0,1,0,0,0,
  102.                          0,1,0,1,0,0,
  103.                          1,0,0,0,1,0,
  104.                          0,1,0,1,0,0,
  105.                          0,0,1,0,0,0,
  106.                          0,0,0,0,0,0};
  107.  
  108. Finally a block of constants which control where on the PCX the program looks
  109. for the font need to be dealt with. These are as follows:
  110.  
  111. const char x_origin=20;            // top left x of first frame in each row
  112. const char row1_y_origin=24;       // top left y of first frame in row #1
  113. const char row2_y_origin=31;           // row #2, and
  114. const char row3_y_origin=38;           // row #3
  115. const char chars_per_row=32;           // number of frames in each row
  116. const char pcxfile[80]="FONT1.PCX";    // source pcx file and path
  117. const char fntfile[80]="CSFONT1.FNT";  // destination font file name /path
  118.  
  119.  
  120. Now run the program. If all is well you will hear a beep after the program
  121. has finished creating the font file. If the above steps were followed corr-
  122. ectly all you will have to do to use the new font is declare an instance of
  123. it: font new_font("newfont.fnt").
  124.  
  125. NOTES: This program is rough, in that it has absolutely no user interface.
  126. If you're not a programmer you'll be hard pressed to use it. if you are a
  127. programmer, and want to add a front end, feel free to do so. This is the first
  128. version, and there will likely be many changes.
  129.  
  130. Support:
  131.  
  132. Support will be provided for these tools where and as possible through mess-
  133. ages posted to 76605,2346 in the Game Design section (sec. 11) of the Gamers
  134. Forum on Compuserve. Sorry, no telephone support is possible.
  135.  
  136.  
  137.